﻿using KingsSharp.Core.Data.Entity;
using CRM.Admin.Contracts.Model.Sys;
using System;

namespace CRM.Admin.Services.EntityConfigurations.Sys
{
    /// <summary>
    /// 菜单目录
    /// </summary>
    public class MenuCatalogConfiguration : EntityConfigurationBase<MenuCatalog, Guid>
    {
        public MenuCatalogConfiguration()
        {
            this.Property(tb => tb.IconColor).HasMaxLength(20);
            this.Property(tb => tb.IconText).HasMaxLength(20);
        }
    }

    /// <summary>
    /// 菜单表
    /// </summary>
    public class MenuNodeConfiguration : EntityConfigurationBase<MenuNode, Guid>
    {
        public MenuNodeConfiguration()
        {
            this.Property(tb => tb.IconColor).HasMaxLength(20);
            this.Property(tb => tb.IconText).HasMaxLength(20);

            this.Property(tb => tb.Description).HasMaxLength(200);
            this.Property(tb => tb.MenuCode).HasMaxLength(50);
            this.Property(tb => tb.MenuURL).HasMaxLength(200);
            this.Property(tb => tb.MenuURLTarget).HasMaxLength(20);

            this.HasRequired(a => a.MenuCatalog).WithMany(b => b.Menus).HasForeignKey(c => c.CatalogId);
        }
    }

    /// <summary>
    /// 功能按钮
    /// </summary>
    public class MenuNodeActionConfiguration : EntityConfigurationBase<MenuNodeAction, int>
    {
        public MenuNodeActionConfiguration()
        {
            this.Property(tb => tb.Name).HasMaxLength(50);
            this.Property(tb => tb.Code).HasMaxLength(50);
            this.HasRequired(a => a.Menu).WithMany(b => b.Actions).HasForeignKey(c => c.MenuId);
        }
    }
}
